{extend name="main/index" /}
{block name="main"}
<div class="main-content">
    <div class="breadcrumbs" id="breadcrumbs">
        <script type="text/javascript">
            try{ace.settings.check('breadcrumbs' , 'fixed')}catch(e){}
        </script>

        <ul class="breadcrumb">
            <li>
                <i class="icon-home home-icon"></i>
                <a href="#">Home</a>
            </li>

            <li>
                <a href="{:url('admin/material/index')}" >Tables</a>
            </li>
            <li class="active">用品入库详情信息</li>
        </ul><!-- .breadcrumb -->

        <div class="nav-search" id="nav-search">
            <form class="form-search">
                <span class="input-icon">
                    <input type="text" placeholder="Search ..." class="nav-search-input" id="nav-search-input" autocomplete="off" />
                    <i class="icon-search nav-search-icon"></i>
                </span>
            </form>
        </div><!-- #nav-search -->
    </div>
    <div class="page-content">
        <div class="row">
        <div class="col-xs-2">
        </div>
            <div class="col-xs-8">
                <div class="row">
                    <div class="col-xs-12">
                        <div class="table-responsive">
                            <form id="themeForm" method="post"  onsumbit ="return false" enctype="multipart/form-data" >

                                   <div class="form-group">
                                       <input type="hidden" class="form-control"  name="id" value= "{$list['id']}">
                                    <label for="exampleInputEmail1">用品名称</label>
                                    <input type="text" class="form-control" id="exampleInputEmail1" placeholder="supplies_name" name="supplies_name" value="{$list['supplies_name']}">
                                  </div>
                                   <div class="form-group">
                                    <label for="exampleInputEmail1">供应商</label>
                                    <input type="text" class="form-control" id="exampleInputEmail1" placeholder="Email" name="supplier" value="{$list['supplier']}">
                                  </div>
                                   <div class="form-group">
                                    <label for="exampleInputEmail1">实际单价</label>
                                    <input type="text" class="form-control" id="a" placeholder="Email"  name="number" value="{$list['number']}">
                                  </div>
                                  <div class="form-group">
                                    <label for="exampleInputEmail1">出库数量</label>
                                    <input type="text" class="form-control" id="b" onkeyup="change(this)"  placeholder="Email"  name="unit_price" value="{$list['unit_price']}">
                                  </div>
                                  <div class="form-group">
                                    <label for="exampleInputPassword1">出库总价</label>
                                    <input type="text" class="form-control" id="c" placeholder="total_price" name="total_price" value="{$list['total_price']}" readonly >
                                      <input type="hidden" id="d" name="in_total_price" class="col-xs-10 col-sm-5" readonly>
                                  </div>
                                <div class="form-group">
                                    <label for="exampleInputPassword1">库存（注意库存数量）</label>
                                    <input type="hidden" id="inventory" value="{$list['inventory']}" >
                                    <input type="text" class="form-control" id="e" placeholder="默认值是1" value="{$list['inventory']}">
                                    <input type="hidden" class="form-control" id="r" placeholder="inventory" name="inventory" value="{$list['inventory']}">
                                </div>
                                  <div class="form-group">
                                  <button  class="btn btn-info up_btn" id="add_Warehouse" >出库确认</button>
                                      <div class="col-xs-8">
                                      </div>
                                      <a href="{:url('admin/office/supplies')}" class="btn btn-info" id="aa" >返回上一级</a>

                                </div>
                            </form>
                    </div>
            </div>
            <div class="col-xs-3">
            </div><!-- /.col -->
        </div><!-- /.row -->
    </div><!-- /.page-content -->
</div>
{/block}

        {block name="myjs"}
        <script>

            function change(obj){
                var a = $('#a').val();
                var e = $('#inventory').val();
                var self = $(obj);
                var b = self.val();
                var c = a * b ;
                var g = e - b ;

                $('#c').val(c);
                $('#d').val(c);

                $('#e').val(g);
                $('#r').val(g);

            }


            $('#add_Warehouse').click(function(){
                id= $('input[type="hidden"]').val();
                upAjax(id);
            });

            function upAjax(id){
                $.ajax({
                    type:'post',
                    url: '/admin/office/updateOffice/id/'+ id,
                    dataType:'json',
                    data:{
                        supplies_name:$('input[name="supplies_name"]').val(),
                        supplier:$('input[name="supplier"]').val(),
                        unit_price:$('input[name="unit_price"]').val(),
                        number:$('input[name="number"]').val(),
                        total_price:$('input[name="total_price"]').val(),
                        inventory:$('input[name="inventory"]').val()

                    },

                    success: function (data) {
                        console.log(data);
                        if (data.status) {
                            alert('成功');
                        } else {
                            alert('失败');
                        }
                    },
                    error: function () {
                        alert('更新执行失败');
                    }
                });
            }

        </script>

        {/block}
